# _*_ coding : utf-8 _*_
# @Time: 2024/10/11 15:23
# @Author : 石文帅	
# @File : testcase02街道人员在线统计.py
# @Project : python_slfh

from server.slfhWorkbench import *
from selenium.webdriver.chrome.service import Service
from xpathDictionary.slfhXpath import *


class test(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.wd = webdriver.Chrome(service=Service(driver_path))
        cls.wd.get(url_path)
        cls.wd.maximize_window()
        login(cls.wd)

    @classmethod
    def tearDownClass(cls):
        cls.wd.quit()
        log.info('----------------------------------------------------------')

    def testcase02街道人员在线统计(self):
        """
        街道人员在线统计
        :return:
        """
        log.info('test2_街道人员在线统计')
        locate_click(self.wd, online_statistics['街道人员在线统计'])
        locate_click(self.wd, online_statistics['统计列表'])
        time.sleep(2)
        locate_click(self.wd, online_statistics['街镇筛选'])
        time.sleep(1)
        self.wd.find_elements(By.XPATH, online_statistics['南山街道'])[1].click()
        locate_click(self.wd, online_statistics['时间筛选'])
        time.sleep(1)
        locate_input(self.wd, online_statistics['统计列表-筛选开始日期'], '2024-09-03')
        locate_input(self.wd, online_statistics['统计列表-筛选结束日期'], '2024-09-03')
        locate_click(self.wd, online_statistics['统计列表-时间筛选确认'])
        time.sleep(1)
        self.assertEqual(self.wd.find_element(By.XPATH, online_statistics['在线时长']).text, '8.6')
        self.assertEqual(self.wd.find_element(By.XPATH, online_statistics['离线时长']).text, '15.4')
        self.assertEqual(self.wd.find_element(By.XPATH, online_statistics['在线率']).text, '35.8%')
        self.wd.find_element(By.XPATH, online_statistics['查看']).click()
        time.sleep(1)

        list1 = ['16687775555', '2024-09-03 12:06:36', '2024-09-03 20:41:46', '8.6']
        assert_list_elements(self.wd, online_statistics['详情列表'], list1)
        locate_click(self.wd, online_statistics['关闭按钮'])
